#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: bubblesort.py 
@version:
@time: 2023/03/29 
"""


def bubblesort(nums):
    n = len(nums) - 1
    for i in range(n):
        flag = True
        for j in range(n - i):
            if nums[j] > nums[j + 1]:
                nums[j], nums[j + 1] = nums[j + 1], nums[j]
                flag = False
        if flag is True: break
    return nums


print(bubblesort([2, 3, 231, 2123, 1]))
